from django.db import models
from houduan.utils.basemodels import BaseModel
# Create your models here.
from index.models import Shop


class User(BaseModel):
    nickname = models.CharField(max_length=100,verbose_name="用户名")
    headimgurl = models.ImageField(verbose_name='头像')
    token  =models.CharField(max_length=500,verbose_name="token验证码")
    phone = models.CharField(max_length=11)
    smscode = models.CharField(max_length=4)

    class Meta:
        db_table = 't_user'
        verbose_name = '用户表'
        verbose_name_plural = verbose_name


class Cart(BaseModel):
    user = models.ForeignKey(User, on_delete=models.PROTECT, verbose_name="订单用户")
    shop = models.ForeignKey(Shop, on_delete=models.PROTECT, verbose_name="商品")
    blessing = models.CharField(max_length = 500, verbose_name='祝福语')
    count = models.IntegerField(verbose_name='购买数量')
    imageUrl = models.ImageField(verbose_name='图片')
    isChecked = models.IntegerField(verbose_name='默认被选中',default=1)
    name = models.CharField(max_length = 10, verbose_name='商品名称')
    price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="实际金额")


    class Meta:
        db_table = 't_cart'
        verbose_name = '购物车'
        verbose_name_plural = verbose_name


class OrderAddress(BaseModel):
    address = models.CharField(max_length = 50, verbose_name='地址')
    cityCode = models.CharField(max_length = 10, verbose_name='城市编号')
    cityName = models.CharField(max_length = 10, verbose_name='城市名')
    districtCode = models.CharField(max_length = 10, verbose_name='地区编号')
    districtName = models.CharField(max_length = 10, verbose_name='地区名')
    fullAddress = models.CharField(max_length = 100, verbose_name='完整地址')
    isDefault = models.IntegerField(verbose_name='默认被选中',default=1)
    isDeleted = models.IntegerField(verbose_name='默认被选中', default=0)
    name = models.CharField(max_length = 10, verbose_name='收款人')
    phone = models.CharField(max_length=11)
    provinceCode = models.CharField(max_length = 10, verbose_name='省编号')
    provinceName  = models.CharField(max_length = 10, verbose_name='省名')
    tagName = models.CharField(max_length = 10, verbose_name='省名')
    user = models.ForeignKey(User, on_delete=models.PROTECT, verbose_name="订单用户")


    class Meta:
        db_table = 't_order_address'
        verbose_name = '订单'
        verbose_name_plural = verbose_name